import type { App } from 'vue';
export const preventReClick = (app: App) => {
  //阻止重复点击（1秒）
  // 使用时加参数v-preventReClick:3000， 3000就是binding.arg
  // 或者v-preventReClick="3000"
  app.directive('preventReClick', {
    created (el:any, binding:any) {
      el.addEventListener('click', () => {
        console.log(el.getBoundingClientRect())
        console.log(el,binding)
        if (!el.disabled) {
          el.disabled = true;
          setTimeout(() => {
            el.disabled = false;
          }, binding.arg || 1000);
        } else {
          console.log('请勿频繁点击')
        }
      })
    }
  })
}